package com.yf.fragmentdynamic;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class FirstFragment extends Fragment implements OnClickListener {

	private SecondFragment sf;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment1, null);
		sf = (SecondFragment) getActivity().getFragmentManager().findFragmentByTag("right");
		Button btn_dev = (Button) view.findViewById(R.id.btn_dev);
		Button btn_sys = (Button) view.findViewById(R.id.btn_sys);
		Button btn_net = (Button) view.findViewById(R.id.btn_net);
		btn_dev.setOnClickListener(this);
		btn_sys.setOnClickListener(this);
		btn_net.setOnClickListener(this);
		
		return view;
	}

	@Override
	public void onClick(View v) {
		System.out.println(v.getId());
		
		sf.setTitle(((Button) v).getText());
		sf.setDesc(((Button) v).getText());

	}
}
